import requests
from retrying import retry


@retry(stop_max_attempt_number=3)
def get_comment(params=None):
    headers = {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "accept-language": "zh-CN,zh;q=0.9",
        "cache-control": "no-cache",
        "pragma": "no-cache",
        "priority": "u=0, i",
        "sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Linux\"",
        "sec-fetch-dest": "document",
        "sec-fetch-mode": "navigate",
        "sec-fetch-site": "same-origin",
        "sec-fetch-user": "?1",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
    }
    cookies = {
        "SINAGLOBAL": "8051481509490.477.1725417483785",
        "SCF": "AiHhHpjpUWHWnw4SPlbn0Blpe01ucnX2MUzKWh0fqSb96uh2rN6GVyJBgMyb4CP0aWNA7WmWLcNlYlY8hYs04yo.",
        "ULV": "1730362247897:2:1:1:2795453509399.395.1730362247887:1725417483789",
        "ALF": "1733559052",
        "SUB": "_2A25KKAZcDeRhGeNJ6VIS-S7EzDWIHXVpRAeUrDV8PUJbkNAbLRjAkW1NS_5D5YxOEMatinDhQIKyoRGoJG2oLmN3",
        "SUBP": "0033WrSXqPxfM725Ws9jqgMF55529P9D9WhmxpO6_7Bbx4r5qcvFEF1M5JpX5KMhUgL.Fo-Neo501K5RS0.2dJLoI0qLxK-LBo5L12qLxK-LBo2L1h2LxK-LB-BLBK.LxKML1-2L1hBLxK-L1K5L12eLxKqLBK2L12et",
        "XSRF-TOKEN": "dON_EZE-rzC882UKUGWD1HKU",
        "PC_TOKEN": "41d5ffa4ab",
        "WBPSESS": "G9Ff9BQjWfN2Zb8Vj7-gc-yXFs3Y9sWM72U5flc0bOD_g3vusEwwgCVT1Zq8J4AHtyRQtKwyQ8ZeFytfBXqGKm3BVm3PZWC--9PF9kcRdgaCfdfWeuzv1nUrrjhQazTX_vzcTwqrGJgLvPogGQFHeA=="
    }
    url = "https://weibo.com/ajax/statuses/buildComments"
    if params == None:
        params = {
            "flow": "1", #按时间
            "is_reload": "1",
            "id": "5067347088642071",
            "is_show_bulletin": "2",
            "is_mix": "0",
            "count": "20",
            # "type": "feed",
            "max_id":0,

            "uid": "2047010597",
            "fetch_level": "0",
            "locale": "zh"
        }

    response = requests.get(url, headers=headers, cookies=cookies, params=params,timeout=10)
    print(response.url,response)
    # print(response.text)
    return response.json()

if __name__ == "__main__":
    print()
    print(get_comment())